home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 173 / 173.xpi / chrome / gm-notifier.jar / content / gm-notifier / gm-login-multi.xul < prev    next >
Extensible Markup Language  |  2009-09-28  |  5KB  |  139 lines

  1. <?xml version="1.0"?>
  2.  
  3. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
  4. <?xml-stylesheet href="chrome://global/skin/browser.css" type="text/css"?>
  5.  
  6. <?xml-stylesheet href="chrome://gm-notifier/content/gm-notifier.css" type="text/css"?>
  7.  
  8. <!DOCTYPE dialog SYSTEM "chrome://gm-notifier/locale/gm-notifier.dtd">
  9.  
  10. <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  11.         id="gm--notifier-login"
  12.         onload="return onLoad();"
  13.         ondialogaccept="return onAccept();"
  14.         buttons="accept"
  15.         title="¬ifier-login.title;" style="padding:0px;"
  16.         persist="screenX screenY">
  17.  
  18.   <script type="application/x-javascript">
  19.     <![CDATA[
  20.     const nsIGMNotifierProgressListener = Components.interfaces.nsIGMNotifierProgressListener;
  21.  
  22.     var gNotifierService = null;
  23.     var gNotifierProgressListener = null;
  24.  
  25.     function onLoad() {
  26.       gNotifierService = Components.classes["@mozilla.org/GMailNotifier;1"].getService(Components.interfaces.nsIGMNotifierService);
  27.  
  28.       // create ui - base on user queue
  29.       var usercount = gNotifierService.getQueueCount();
  30.  
  31.       var username, row, label, image, progress, button;
  32.       var rows = document.getElementById("userrows");
  33.       for (var i = 0; i < usercount; i++) {
  34.         username = gNotifierService.getQueueUserName(i);
  35.  
  36.         row = document.createElement("row");
  37.         row.setAttribute("align", "center");
  38.         row.className = "multilogin-row";
  39.  
  40.         label = document.createElement("label");
  41.         label.setAttribute("value", username);
  42.         row.appendChild(label);
  43.  
  44.         image = document.createElement("image");
  45.         image.setAttribute("id", "progress-image-"+username);
  46.         row.appendChild(image);
  47.  
  48.         progress = document.createElement("progressmeter");
  49.         progress.setAttribute("id", "progress-" + username);
  50.         progress.setAttribute("value", 0);
  51.         progress.setAttribute("mode", "undetermined");
  52.         row.appendChild(progress);
  53.  
  54.         rows.appendChild(row);
  55.       }
  56.  
  57.       // register listener
  58.       gNotifierProgressListener = new NotifierProgressListener();
  59.       gNotifierService.addListener(gNotifierProgressListener);
  60.  
  61.       gNotifierService.checkNow();
  62.     }
  63.  
  64.     var NotifierProgressListener = function() {
  65.       return ({
  66.         getID : function () { return null; },
  67.  
  68.         onStateChange : function (aUsername, aState) {
  69.           var progressMeter = document.getElementById("progress-" + aUsername);
  70.  
  71.           if (aState == nsIGMNotifierProgressListener.LOGIN_INITIATED) {
  72.             progressMeter.setAttribute("mode", "determined");
  73.             progressMeter.setAttribute("value", "33%");
  74.             document.getElementById("progress-image-" + aUsername).setAttribute("src", "chrome://global/skin/throbber/Throbber-small.gif");
  75.           } else if (aState == nsIGMNotifierProgressListener.LOGIN_FAILED) {
  76.             var label = document.createElement("label");
  77.             label.setAttribute("value", getStringFromBundle("LoggingStatusFailed1"));
  78.             progressMeter.parentNode.replaceChild(label, progressMeter);
  79.  
  80.             document.getElementById("progress-image-" + aUsername).removeAttribute("src");
  81.           } else if (aState == nsIGMNotifierProgressListener.LOGIN_DETAILS_INVALID) {
  82.             var label = document.createElement("label");
  83.             label.setAttribute("value", getStringFromBundle("UserStateInvalidDetails"));
  84.             progressMeter.parentNode.replaceChild(label, progressMeter);
  85.  
  86.             document.getElementById("progress-image-" + aUsername).removeAttribute("src");
  87.           } else if (aState == nsIGMNotifierProgressListener.LOGIN_SUCCESS) {
  88.             progressMeter.setAttribute("value", "66%");
  89.           } else if (aState == nsIGMNotifierProgressListener.NO_NEW_MAIL || aState == nsIGMNotifierProgressListener.NEW_MAIL) {
  90.             progressMeter.setAttribute("value", "100%");
  91.             document.getElementById("progress-image-" + aUsername).removeAttribute("src");
  92.           } else if (aState == nsIGMNotifierProgressListener.ACCOUNTS_CHECK_COMPLETED) {
  93.             // give a small timeout interval to let the UI finish it's updating
  94.             setTimeout(onAccept, 800);
  95.           }
  96.         },
  97.  
  98.         QueryInterface : function(aIID) {
  99.           if (aIID.equals(nsIGMNotifierProgressListener) ||
  100.               aIID.equals(Components.interfaces.nsISupports))
  101.             return this;
  102.           throw Components.results.NS_NOINTERFACE;
  103.         }
  104.       });
  105.     }
  106.  
  107.     function getStringFromBundle(aName) {
  108.       var strbundle = document.getElementById("strings");
  109.       return strbundle.getString(aName);
  110.     }
  111.  
  112.     function onAccept() {
  113.       // unregister listener
  114.       gNotifierService.removeListener(gNotifierProgressListener);
  115.  
  116.       // cleanup
  117.       gNotifierProgressListener = null;
  118.       gNotifierService = null;
  119.  
  120.       window.close();
  121.     }
  122.     ]]>
  123.   </script>
  124.  
  125.   <stringbundle id="strings" src="chrome://gm-notifier/locale/gm-notifier.properties"/>
  126.  
  127.   <grid class="multilogin-users">
  128.     <columns>
  129.       <column />
  130.       <column style="min-width:16px;"/>
  131.       <column flex="1"/>
  132.     </columns>
  133.  
  134.     <rows id="userrows">
  135.     </rows>
  136.   </grid>
  137. </dialog>
  138.  
  139.